<template>
  <div>
    <Dog
      v-for="(obj, index) in arr"
      :key="index"
      :imgurl="obj.dogImgUrl"
      :dogname="obj.dogName"
      @love="fn"
    ></Dog>

    <hr />
    <p>显示喜欢的狗:</p>
    <ul>
      <li v-for="(item, index) in loveArr" :key="index">{{ item }}</li>
    </ul>

  </div>
</template>
 
<script>
import Dog from "./components/Dog2.vue";
export default {
  data() {
    return {
      arr: [
        {
          dogImgUrl:
            "http://nwzimg.wezhan.cn/contents/sitefiles2029/10146688/images/21129958.jpg",
          dogName: "博美",
        },
        {
          dogImgUrl:
            "https://img1.baidu.com/it/u=1691220372,53278101&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=499",
          dogName: "泰迪",
        },
        {
          dogImgUrl:
            "https://img1.baidu.com/it/u=3086392159,2444042157&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=554",
          dogName: "金毛",
        },
        {
          dogImgUrl:
            "https://pic1.zhimg.com/80/v2-7ba4342e6fedb9c5f3726eb0888867da_1440w.jpg?source=1940ef5c",
          dogName: "哈士奇",
        },
        {
          dogImgUrl:
            "https://img0.baidu.com/it/u=2868473159,2341938328&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=379",
          dogName: "阿拉斯加",
        },
        {
          dogImgUrl:
            "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fai-dogs.com%2FupLoad%2Fimage%2F20160117%2F14530164269221449.jpg&refer=http%3A%2F%2Fai-dogs.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1666510524&t=e147adc2e6f0061956a0bccf3638bcd3",
          dogName: "萨摩耶",
        },
      ],
      loveArr: [],
    };
  },
  components: {
    Dog,
  },
  methods: {
    fn(dogName) {
      this.loveArr.push(dogName);
    },
  },
}
</script>